<?php
	include "../public/commom/config.php";//引入配置连接数据库文件
	include "../public/commom/commom.php";//引入配置图片文件
	
	if(isset($_SESSION["user_id"])) {
		if($_POST) {
			$content = $_POST["content"];//私信内容
			$time = time();//时间戳
			$user_id = $_POST["tuser_id"];//接收私信用户ID
			$tuser_id = $_SESSION["user_id"];//发送私信用户ID
			
			$sql = "INSERT INTO privateletter (content, time, user_id, tuser_id) VALUES ('$content', '$time', '$user_id', '$tuser_id')";//sql语句  - 发送私信
			
			$result = mysqli_query($conn, $sql);//result - 执行sql语句
			
			mysqli_close($conn);//关闭数据库连接
			
			echo "<script>location.href='" . $_SERVER["HTTP_REFERER"] . "';</script>";//返回上一页
		}
	}else {
		echo "您未登录，请登录。";
		exit;
	}
?>